use carpet::base::error::ServerError;
use template_api::api::demo::text::*;
use crate::api::prelude::*;

#[derive(Handler)]
pub struct Handler {

}

#[impl_handler(HandleDef_)]
impl Handler {
    async fn _handle(self, data: Json<RequestData>) -> Result<ResponseData, Error> {
        let req = data.0;
        if req.title.eq("error") {
            return Err(ServerError(anyhow::anyhow!("测试错误")).into());
        }
        Ok(ResponseData { title: req.title, age: req.age, description: req.description })
    }
}